using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI.Design;

namespace Acms.DataControls
{
    public abstract class GenericDataSourceDesigner<Item> : DataSourceDesigner
    {

        private GenericDataSourceDesignerView<Item> view;
        public override DesignerDataSourceView GetView(string viewName)
        {
            if (view == null)
            {
                view = new GenericDataSourceDesignerView<Item>(this, viewName);
            }
            return view;
        }

        public virtual bool CanDelete
        {
            get { return true; }
        }

        public virtual bool CanInsert
        {
            get { return true; }
        }

        public virtual bool CanPage
        {
            get { return true; }
        }

        public virtual bool CanRetrieveTotalRowCount
        {
            get { return true; }
        }

        public virtual bool CanSort
        {
            get { return true; }
        }

        public virtual bool CanUpdate
        {
            get { return true; }
        }

        internal virtual System.Collections.IEnumerable GetDesignTimeData(int minimumRows, out bool isSampleData)
        {
            System.Collections.Generic.List<Item> tmp = new List<Item>();
            for (int i = 0; i < minimumRows; i++)
            {
                tmp.Add(GetDesignTimeItem(i));
            }
            isSampleData = true;
            return tmp.ToArray();
        }

        protected abstract Item GetDesignTimeItem(int index);
    }
}
